{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "feb9fa8c",
   "metadata": {},
   "source": [
    "统计端基文件夹内potcar的版本"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "d6eb63ac",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "AW Ag_GW 06Mar2008\n",
      "AW Al_GW 19Mar2012\n",
      "AW Al_sv_GW 2Feb2008\n",
      "AW Ar_GW 02Oct2006\n",
      "AW As_GW 20Mar2012\n",
      "AW At 21May2007\n",
      "AW Au_GW 23Mar2010\n",
      "AW Au_pv_GW 23Mar2010\n",
      "AW B 28Sep2005\n",
      "AW Ba_sv_GW 23Mar2010\n",
      "AW Be_GW 04Mar2008\n",
      "AW Be_sv_GW 31Mar2010\n",
      "AW Bi_GW 07Mar2011\n",
      "AW Bi_d_GW 22Apr2009\n",
      "AW C_GW 28Sep2005\n",
      "AW C_GW_new 19Mar2012\n",
      "AW Ca_sv_GW 31Mar2010\n",
      "AW Cd_f_GW 18May2010\n",
      "AW Cd_pv 30Sep2005\n",
      "AW Cd_sv 30Sep2005\n",
      "AW Ce_GW 26Mar2009\n",
      "AW Cl_GW 19Mar2012\n",
      "AW Co_GW 31Mar2010\n",
      "AW Co_sv_GW 27Nov2009\n",
      "AW Cr_sv_GW 31Mar2010\n",
      "AW Cs_sv_GW 23Mar2010\n",
      "AW Cu_GW 19May2006\n",
      "AW Cu_pv_GW 12Sep2006\n",
      "AW F_GW 19Mar2012\n",
      "AW F_GW 21Dec2007\n",
      "AW Fe_GW 31Mar2010\n",
      "AW Fe_sv_GW 31Mar2010\n",
      "AW Ga_GW 22Mar2012\n",
      "AW Ga_d_GW 06Jul2010\n",
      "AW Ga_pv_GW 23May2007\n",
      "AW Ga_sv_GW 23May2007\n",
      "AW Ge 04Okt2005\n",
      "AW Ge_d_GW 17Dec2007\n",
      "AW Ge_sv_GW 11Sep2010\n",
      "AW H.25 05Aug2008\n",
      "AW H.33 22Sep2006\n",
      "AW H.42 19Jan2011\n",
      "AW H.58 19Jan2011\n",
      "AW H.66 06Jun2006\n",
      "AW H1.33 06Jun2006\n",
      "AW H1.66 22Sep2006\n",
      "AW H1.75 05Aug2008\n",
      "AW H_GW 21Apr2008\n",
      "AW H_h_GW 21Apr2008\n",
      "AW He_GW 13May2007\n",
      "AW Hf_sv_GW 25Mar2010\n",
      "AW In_d_GW 29May2007\n",
      "AW Ir_sv_GW 23Mar2010\n",
      "AW K_sv_GW 31Mar2010\n",
      "AW Kr_GW 02Oct2006\n",
      "AW Li_AE_GW 25Mar2010\n",
      "AW Li_GW 11May2007\n",
      "AW Li_sv_GW 25Mar2010\n",
      "AW Mg_GW 13Apr2007\n",
      "AW Mg_pv_GW 20Apr2010\n",
      "AW Mg_sv_GW 20Apr2010\n",
      "AW Mn_GW 31Mar2010\n",
      "AW Mn_sv_GW 27Nov2009\n",
      "AW Mo_sv_GW 23Mar2010\n",
      "AW N_GW 10Apr2007\n",
      "AW N_GW_new 19Mar2012\n",
      "AW N_s_GW 04Apr2007\n",
      "AW Na_sv_GW 08Feb2008\n",
      "AW Nb_sv_GW 23Mar2010\n",
      "AW Ne_GW 02Oct2006\n",
      "AW Ne_GW 02Oct2006\n",
      "AW Ni_GW 31Mar2010\n",
      "AW Ni_sv_GW 27Nov2009\n",
      "AW O_GW 19Mar2012\n",
      "AW O_GW 28Sep2005\n",
      "AW O_s_GW 10Jan2007\n",
      "AW Os_sv_GW 23Mar2010\n",
      "AW P_GW 19Mar2012\n",
      "AW Pb_d 06Oct2005\n",
      "AW Pd_GW 06Mar2008\n",
      "AW Pt_GW 10Mar2009\n",
      "AW Pt_pv_GW 23Mar2010\n",
      "AW Pt_sv_GW 23Mar2010\n",
      "AW Rb_sv_GW 23Mar2010\n",
      "AW Re_sv_GW 23Mar2010\n",
      "AW Rh_GW 06Mar2008\n",
      "AW Rh_pv_GW 18Jan2008\n",
      "AW Rh_sv_GW 20Mar2012\n",
      "AW Ru_pv_GW 17Apr2009\n",
      "AW Ru_sv_GW 23Mar2010\n",
      "AW S_GW 19Mar2012\n",
      "AW Sb_GW 21Mar2012\n",
      "AW Sb_d_GW 22Apr2009\n",
      "AW Sc_sv_GW 23Mar2010\n",
      "AW Se_GW 20Mar2012\n",
      "AW Si_GW 04May2012\n",
      "AW Si_sv_GW 29Sep2009\n",
      "AW Sr_sv_GW 23Mar2010\n",
      "AW Ta_sv_GW 23Mar2010\n",
      "AW Tc_sv_GW 23Mar2010\n",
      "AW Te_GW 22Mar2012\n",
      "AW Ti_sv_GW 23Mar2010\n",
      "AW V_sv_GW 31Mar2010\n",
      "AW W_sv_GW 23Mar2010\n",
      "AW Xe_GW 08Jan2009\n",
      "AW Y_sv_GW 23Mar2010\n",
      "AW Zn_GW 09Oct2010\n",
      "AW Zn_pv_GW 09Oct2010\n",
      "AW Zn_sv_GW 01Dec2010\n",
      "AW Zr_sv_GW 07Apr2010\n",
      "AW_GGA Ru_sv 28Jan2005\n",
      "AW_PBE Ac 06Sep2000\n",
      "AW_PBE Ag 02Apr2005\n",
      "AW_PBE Ag_pv 09Dec2005\n",
      "AW_PBE Al 04Jan2001\n",
      "AW_PBE Am 08May2007\n",
      "AW_PBE Ar 07Sep2000\n",
      "AW_PBE As 22Sep2009\n",
      "AW_PBE As_d 11Apr2003\n",
      "AW_PBE At_d 21May2007\n",
      "AW_PBE Au 04Oct2007\n",
      "AW_PBE B 06Sep2000\n",
      "AW_PBE B_h 06Feb2004\n",
      "AW_PBE B_s 22Jan2003\n",
      "AW_PBE Ba_sv 06Sep2000\n",
      "AW_PBE Be 06Sep2000\n",
      "AW_PBE Be_sv 06Sep2000\n",
      "AW_PBE Bi 08Apr2002\n",
      "AW_PBE Bi_d 06Sep2000\n",
      "AW_PBE Br 06Sep2000\n",
      "AW_PBE Br 20Mar2012\n",
      "AW_PBE C 08Apr2002\n",
      "AW_PBE C_h 06Feb2004\n",
      "AW_PBE C_s 06Sep2000\n",
      "AW_PBE Ca_pv 06Sep2000\n",
      "AW_PBE Ca_sv 06Sep2000\n",
      "AW_PBE Cd 06Sep2000\n",
      "AW_PBE Ce 23Dec2003\n",
      "AW_PBE Ce_3 06Sep2000\n",
      "AW_PBE Ce_h 03Mar2005\n",
      "AW_PBE Cl 06Sep2000\n",
      "AW_PBE Cl_h 21Jan2003\n",
      "AW_PBE Cm 17Jan2011\n",
      "AW_PBE Co 02Aug2007\n",
      "AW_PBE Co_pv 23Apr2009\n",
      "AW_PBE Co_sv 23Jul2007\n",
      "AW_PBE Cr 06Sep2000\n",
      "AW_PBE Cr_pv 02Aug2007\n",
      "AW_PBE Cr_sv 23Jul2007\n",
      "AW_PBE Cs_sv 08Apr2002\n",
      "AW_PBE Cu 22Jun2005\n",
      "AW_PBE Cu_pv 06Sep2000\n",
      "AW_PBE Dy 23Dec2003\n",
      "AW_PBE Dy_3 06Sep2000\n",
      "AW_PBE Er 01Sep2006\n",
      "AW_PBE Er_2 17Jan2003\n",
      "AW_PBE Er_3 06Sep2000\n",
      "AW_PBE Eu 23Dec2003\n",
      "AW_PBE Eu_2 06Sep2000\n",
      "AW_PBE Eu_3 20Oct2008\n",
      "AW_PBE F 08Apr2002\n",
      "AW_PBE F_h 06Feb2004\n",
      "AW_PBE F_s 06Sep2000\n",
      "AW_PBE Fe 06Sep2000\n",
      "AW_PBE Fe_pv 02Aug2007\n",
      "AW_PBE Fe_sv 23Jul2007\n",
      "AW_PBE Fr_sv 29May2007\n",
      "AW_PBE Ga 08Apr2002\n",
      "AW_PBE Ga_d 06Jul2010\n",
      "AW_PBE Ga_h 09Apr2002\n",
      "AW_PBE Gd 23Dec2003\n",
      "AW_PBE Gd_3 06Sep2000\n",
      "AW_PBE Ge 05Jan2001\n",
      "AW_PBE Ge_d 03Jul2007\n",
      "AW_PBE Ge_h 09Apr2002\n",
      "AW_PBE H 15Jun2001\n",
      "AW_PBE H.5 07Sep2000\n",
      "AW_PBE H.75 07Sep2000\n",
      "AW_PBE H1.25 07Sep2000\n",
      "AW_PBE H1.5 07Sep2000\n",
      "AW_PBE H_h 06Feb2004\n",
      "AW_PBE H_s 15May2010\n",
      "AW_PBE He 05Jan2001\n",
      "AW_PBE Hf 20Jan2003\n",
      "AW_PBE Hf_pv 06Sep2000\n",
      "AW_PBE Hf_sv 10Jan2008 GW suitable\n",
      "AW_PBE Hg 06Sep2000\n",
      "AW_PBE Ho 23Dec2003\n",
      "AW_PBE Ho_3 06Sep2000\n",
      "AW_PBE I 08Apr2002\n",
      "AW_PBE I_GW 12Mar2012\n",
      "AW_PBE In 08Apr2002\n",
      "AW_PBE In_d 06Sep2000\n",
      "AW_PBE Ir 06Sep2000\n",
      "AW_PBE K_pv 17Jan2003\n",
      "AW_PBE K_sv 06Sep2000\n",
      "AW_PBE Kr 07Sep2000\n",
      "AW_PBE La 06Sep2000\n",
      "AW_PBE La_s 06Sep2000\n",
      "AW_PBE Li 17Jan2003\n",
      "AW_PBE Li_sv 10Sep2004\n",
      "AW_PBE Lu 23Dec2003\n",
      "AW_PBE Lu_3 06Sep2000\n",
      "AW_PBE Mg 13Apr2007\n",
      "AW_PBE Mg_pv 13Apr2007\n",
      "AW_PBE Mg_sv 12Apr2007\n",
      "AW_PBE Mn 06Sep2000\n",
      "AW_PBE Mn_pv 02Aug2007\n",
      "AW_PBE Mn_sv 23Jul2007\n",
      "AW_PBE Mo 08Apr2002\n",
      "AW_PBE Mo_pv 04Feb2005\n",
      "AW_PBE Mo_sv 02Feb2006\n",
      "AW_PBE N 08Apr2002\n",
      "AW_PBE N_h 06Feb2004\n",
      "AW_PBE N_s 07Sep2000\n",
      "AW_PBE Na 08Apr2002\n",
      "AW_PBE Na_pv 19Sep2006\n",
      "AW_PBE Na_sv 28Sep2000\n",
      "AW_PBE Nb_pv 08Apr2002\n",
      "AW_PBE Nb_sv 25May2007\n",
      "AW_PBE Nd 23Dec2003\n",
      "AW_PBE Nd_3 06Sep2000\n",
      "AW_PBE Ne 05Jan2001\n",
      "AW_PBE Ni 02Aug2007\n",
      "AW_PBE Ni_pv 06Sep2000\n",
      "AW_PBE Np 06Sep2000\n",
      "AW_PBE Np_s 06Sep2000\n",
      "AW_PBE O 08Apr2002\n",
      "AW_PBE O_h 06Feb2004\n",
      "AW_PBE O_s 07Sep2000\n",
      "AW_PBE Os 17Jan2003\n",
      "AW_PBE Os_pv 20Jan2003\n",
      "AW_PBE P 06Sep2000\n",
      "AW_PBE P_h 08Apr2002\n",
      "AW_PBE Pa 07Sep2000\n",
      "AW_PBE Pa_s 07Sep2000\n",
      "AW_PBE Pb 08Apr2002\n",
      "AW_PBE Pb_d 06Sep2000\n",
      "AW_PBE Pd 04Jan2005\n",
      "AW_PBE Pd_pv 28Jan2005\n",
      "AW_PBE Pm 23Dec2003\n",
      "AW_PBE Pm_3 07Sep2000\n",
      "AW_PBE Po 10Feb2004\n",
      "AW_PBE Po_d 25May2007\n",
      "AW_PBE Pr 23Dec2003\n",
      "AW_PBE Pr_3 07Sep2000\n",
      "AW_PBE Pt 04Feb2005\n",
      "AW_PBE Pt_pv 12Dec2005\n",
      "AW_PBE Pu 06Sep2000\n",
      "AW_PBE Pu_s 06Sep2000\n",
      "AW_PBE Ra_sv 29May2007\n",
      "AW_PBE Rb_pv 06Sep2000\n",
      "AW_PBE Rb_sv 06Sep2000\n",
      "AW_PBE Re 17Jan2003\n",
      "AW_PBE Re_pv 06Sep2000\n",
      "AW_PBE Rh 04Feb2005\n",
      "AW_PBE Rh_pv 25Jan2005\n",
      "AW_PBE Rn 28Aug2006\n",
      "AW_PBE Ru 04Feb2005\n",
      "AW_PBE Ru_pv 28Jan2005\n",
      "AW_PBE S 06Sep2000\n",
      "AW_PBE S_h 08Apr2002\n",
      "AW_PBE Sb 06Sep2000\n",
      "AW_PBE Sc 04Feb2005\n",
      "AW_PBE Sc_sv 07Sep2000\n",
      "AW_PBE Se 06Sep2000\n",
      "AW_PBE Si 05Jan2001\n",
      "AW_PBE Sm 23Dec2003\n",
      "AW_PBE Sm_3 07Sep2000\n",
      "AW_PBE Sn 08Apr2002\n",
      "AW_PBE Sn_d 06Sep2000\n",
      "AW_PBE Sn_d_GW 20Mar2012\n",
      "AW_PBE Sr_sv 07Sep2000\n",
      "AW_PBE Ta 17Jan2003\n",
      "AW_PBE Ta_pv 07Sep2000\n",
      "AW_PBE Tb 23Dec2003\n",
      "AW_PBE Tb_3 06Sep2000\n",
      "AW_PBE Tc 04Feb2005\n",
      "AW_PBE Tc_pv 04Feb2005\n",
      "AW_PBE Tc_sv 23Mar2010\n",
      "AW_PBE Te 08Apr2002\n",
      "AW_PBE Th 07Sep2000\n",
      "AW_PBE Th_s 06Sep2000\n",
      "AW_PBE Ti 08Apr2002\n",
      "AW_PBE Ti_pv 07Sep2000\n",
      "AW_PBE Ti_sv 26Sep2005\n",
      "AW_PBE Tl 08Apr2002\n",
      "AW_PBE Tl_d 06Sep2000\n",
      "AW_PBE Tm 23Dec2003\n",
      "AW_PBE Tm_3 20Jan2003\n",
      "AW_PBE U 06Sep2000\n",
      "AW_PBE U_s 06Sep2000\n",
      "AW_PBE V 08Apr2002\n",
      "AW_PBE V_pv 07Sep2000\n",
      "AW_PBE V_sv 02Aug2007\n",
      "AW_PBE W 08Apr2002\n",
      "AW_PBE W_pv 06Nov2007\n",
      "AW_PBE Xe 07Sep2000\n",
      "AW_PBE Y_sv 25May2007\n",
      "AW_PBE Yb 23Dec2003\n",
      "AW_PBE Yb_2 06Sep2000\n",
      "AW_PBE Zn 06Sep2000\n",
      "AW_PBE Zr_sv 04Jan2005\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "import re\n",
    "import glob\n",
    "\n",
    "dirpath = '/mnt/c/Users/bar/Downloads/potpaw54/potpaw54/potpaw_PBE/PAW_GGA_PBE'\n",
    "\n",
    "potcar_files = glob.glob(os.path.join(dirpath, '**', 'POTCAR'))\n",
    "vers = []\n",
    "for potcar in potcar_files:\n",
    "    with open(potcar, 'r', encoding='utf-8') as f:\n",
    "        text = f.read()\n",
    "    pattern = r'TITEL\\s.\\=\\s.([^\\r\\n]+)'\n",
    "    matches = re.findall(pattern, text)\n",
    "    if not matches:\n",
    "        continue\n",
    "    vers.extend(m.strip() for m in matches)\n",
    "vers.sort()\n",
    "for v in vers:\n",
    "    print(v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "aa532183",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "AW_PBE Hf_sv 10Jan2008 GW suitable\n",
      "{'2008': 11, '2012': 18, '008': 1, '2006': 14, '2007': 35, '2010': 45, '2005': 26, '2011': 4, '2009': 12, '2000': 74, '2001': 6, '2003': 25, '2004': 8, '2002': 23}\n"
     ]
    }
   ],
   "source": [
    "# vers 词频统计\n",
    "ver_dict = {}\n",
    "for ver in vers:\n",
    "    try:\n",
    "        \n",
    "        sour, elem, times = ver.split(\" \")\n",
    "    except:\n",
    "        print(ver)\n",
    "        continue\n",
    "    years = times[5:]\n",
    "    if years not in ver_dict:\n",
    "        ver_dict[years] = 1\n",
    "    else:\n",
    "        ver_dict[years] += 1\n",
    "print(ver_dict)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "sofs",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
